<?php
session_start();
if(!isset($_SESSION['user'])) die ('请你先登陆<a href=/index.php>login</a>');
require('../config.php');
mysql_select_db(SAE_MYSQL_DB,$conn) or die("数据库".SAE_MYSQL_DB."连接失败!");
$spuser=$_SESSION['uid'];
 if(isset($_POST['spend'])){
 //get the form data
$spendname=trim($_POST['spendname']);
$spendcost=(float)trim($_POST['spendcost']);
$spendopt=$_POST['spendopt'];
$spendsay=trim($_POST['spendsay']);
$spendtime=$_POST['spendtime'];
//****************
$sqlinsert="insert into sp(spuserid,spname,spmoney,spopt,spsay,sptime,spendor)values('$spuser','$spendname','$spendcost','$spendopt','$spendsay','$spendtime',1)";
mysql_query("set names ’utf8’ ");  
$regspend=mysql_query($sqlinsert,$conn); 
if($regspend) 
	 {
		$url="/user/success.html";;
		header("Location: $url");
		//echo "操作成功";
		#echo $spendname;
	 }


}elseif(isset($_GET['shouru'])){
$shouruname=substr($_GET['shouruname'],0,12);
$shourumoney=(float)$_GET['shourumoney'];
$shouruopt=$_GET['shouruopt'];
$shourusay=substr($_GET['shourusay'],0,48);
$shourutime=$_GET['shourutime'];
$shouruinsert="insert into sp(spuserid,spname,spmoney,spopt,spsay,sptime,spendor)values('$spuser','$shouruname','$shourumoney','$shouruopt','$shourusay','$shourutime',2)";
$regs=mysql_query($shouruinsert,$conn);
if($regs) echo "操作成功";
}
else{
    $url="/user/error.html";;
	header("Location: $url");
    //echo "<script>window.alert(\"操作失败\");</script><h1><a href='inout.html'>系统忙,请稍后重试!</a></h1>";
}


?>




